<template>
    <div class=''>
        <el-button type="primary" @click="model={};$refs.d.show();">添加分类</el-button>
        <MyTab :cols="cols"  :data="list" :loading="queryLoading">
        <template v-slot:action="{row}">
            <el-button type="primary">编辑</el-button>
            <el-button type="danger" @click="delgoodsClass(row)">删除</el-button>
        </template>
        </MyTab>
        <DF :title="title + '分类名称'" v-model="model" ref="d" @confirm="confirm" lw="80px" />
    </div>
</template>

<script>
import { timeStamp } from 'console';
import { updataeGoods } from '../../../../do/src/api/goods';
import { goodslist } from '../../../../项目作业/src/api/goods';

export default {
    name:goodslist,
    data() {
        return {
            /**
             * 列
             */
            cols:[
                {
                    title:'#',
                    type:'index',
                },
                {
                    title:'分类名称',
                    name:'expand,cat_name',
                },
                {
                    title:'是否有效',
                    name:'cat_deleted',
                },
                {
                    title:'排序',
                    name:'cat_level',
                },
                {
                    title:'操作',
                    align:center,
                    width:300,
                    slot:'action'
                }
            ]
        };
    },
    mounted() {},
    methods: {
        /**
         * 修改商品分类
         */
        async updataeGoods(){
            const d =this.$refs.d;
            try {
                d.start();
                await updataeGoods(this.model.id,keys.join(","));
                this.goodslistgetClass();
                this.$m.success('修改成功');
                d.hide();
            } catch (error) {}
            d.stop();
        },
        /**
         * 提交
         */
        async confirm() {
            const d =this.$refs.d;
            try {
                d.start();
                await(this.model.id ? modifyRole : addRole)(this.model)
                this.$m.success(this.title+'角色成功')
                d.hide();
                this.goodslistgetClass();
            } catch (error) {}
            d.stop();
        },
        /**
         * 获取分类数据
         */
        async goodslistgetClass(){
            try {
                this.queryLoading = true;
                this.list = this.goodslist();
            } catch (error) {}
            this.queryLoading = false;
        },
        /**
         * 删除商品分类
         */
        async delgoodsClass({goodsName,id}){
            let res;
            try {
                res = await this.$myConfirm(`您确定要删除【${goosName}】吗?`);
                this.delgoodsClass(id);
                this.$m.success("权限删除成功");
                this.goodslistgetClass()
            } catch (error) {}
            res && res();
        }
    },
    components:{}
};
</script>

<style lang='scss'>

</style>
